import Vue from 'vue'
import Vuex from 'vuex'
import * as actions from './actions'
import * as getters from './getters'

Vue.use(Vuex)

// 应用初始状态
const state = {
    count: 10,
	id: '123456',
	openedTab: ['index'],
	activeTab: ''
}

// 定义所需的 mutations
const mutations = {
    INCREMENT(state) {
        state.count++
    },
    DECREMENT(state) {
        state.count--
    },
	addTab (state, componentName) {
		alert('11111')
	  state.openedTab.push(componentName)
	},
	changeTab (state, componentName) {
	  state.activeTab = componentName
	},
	deductTab (state, componentName) {
	  let index = state.openedTab.indexOf(componentName)
	  state.openedTab.splice(index, 1)
	}
}

// 创建 store 实例
export default new Vuex.Store({
    actions,
    getters,
    state,
    mutations
})
